<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich">

<ui:composition template="#{store.templatePath}/template.xhtml">
    <ui:define name="title">Оформление заказа — подтверждение</ui:define>

    <ui:define name="menu"></ui:define>
    <ui:define name="cart"></ui:define>
    <ui:define name="sidebar"></ui:define>

    <ui:define name="body">

        <div class="orderBreadcrumbs"><span>#{messages.cart}</span> → <span>#{messages.authorization}</span> → <span>#{messages.delivery}</span> → <span>#{messages.pay}</span> → <span class="current">#{messages.confirmation}</span></div>


        <h:form>

            <h:dataTable id="cartTable"
                         styleClass="cartTable"
                         columnClasses="cartCell,cartCell,cartCell,cartCell"
                         value="#{cart.order.lines}" var="l"
                         cellspacing="1">

                <h:column>
                    <s:link view="/product.xhtml" propagation="none">
                        <f:param name="cat" value="#{l.product.categories.toArray()[0].id}"/>
                        <f:param name="alias" value="#{l.product.urlAlias}"/>
                        <h:graphicImage value="#{l.product.urlImageSmall}"
                                            alt="#{l.product.name}"
                                            rendered="#{l.product.urlImageSmall != null}" styleClass="cartProductImage" />
                         <h:graphicImage value="/r/pi/#{l.product.urlAlias}-s.jpg"
                                            alt="#{l.product.name}"
                                            rendered="#{l.product.urlImageSmall == null}" styleClass="cartProductImage" />
                    </s:link>
                </h:column>

                <h:column>
                    <f:facet name="header">
                        Товар
                    </f:facet>
                    <s:link view="/product.xhtml" value="#{l.product.name}" propagation="none">
                        <f:param name="cat" value="#{l.product.categories.toArray()[0].id}"/>
                        <f:param name="alias" value="#{l.product.urlAlias}"/>
                    </s:link>
                    <div class="product-description">#{l.product.description}</div>
                </h:column>

                <h:column headerClass="quantityColumn">
                    <f:facet name="header">
                        Количество
                    </f:facet>
                    <h:outputText value="#{l.quantity}" />
                </h:column>

                <h:column headerClass="priceColumn" footerClass="cartTotal">
                    <f:facet name="header">
                        Стоимость
                    </f:facet>
                    <div class="product-price">
                        <span class="product-price-digits">
                            <h:outputText value="#{l.quantity*l.product.price}">
                                <f:convertNumber type="currency" currencySymbol=""/>
                            </h:outputText>
                        </span> руб.
                    </div>

                </h:column>

            </h:dataTable>

            <table width="700px" cellspacing="9" cellpadding="0">
                <tr>
                    <td width="450px"></td>
                    <td align="right" width="120px" style="padding-right: 25px;">Товары:</td>
                    <td width="120px">
                        <div class="product-price">
                            <span class="product-price-digits">
                                <h:outputText value="#{cart.subTotal}">
                                    <f:convertNumber type="currency" currencySymbol=""/>
                                </h:outputText></span> руб.
                        </div>
                    </td>
                </tr>

                <tr>
                    <td width="450px"></td>
                    <td align="right" width="130px" style="padding-right: 25px;">Доставка:</td>
                    <td width="120px">
                        <div class="product-price">
                            <span class="product-price-digits">
                                <h:outputText value="#{cart.deliveryCost}">
                                    <f:convertNumber type="currency" currencySymbol=""/>
                                </h:outputText></span> руб.
                        </div>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td align="right" style="padding-right: 25px;">Итого:</td>
                    <td class="cartTotal">
                        <h:outputText value="#{cart.totalCost}">
                             <f:convertNumber type="currency" currencySymbol="р."/>
                        </h:outputText>
                    </td>
                </tr>
            </table>




            <h:panelGrid columns="2">
                <h:outputText value="#{messages.deliveryType}:" /> <h:outputText value="#{currentOrder.deliveryType.name}" />
                <h:outputText value="#{messages.paymentType}:" /> <h:outputText value="#{currentOrder.paymentType.name}" />

                <h:outputText value="#{messages.receiver}:" /> <h:outputText value="#{currentOrder.customer.firstName} #{currentOrder.customer.fatherName} #{currentOrder.customer.lastName}" />
                <h:outputText value="#{messages.phone}:" /> <h:outputText value="#{currentOrder.customer.phone}" />

                <h:outputText value="#{messages.region}:" /> <h:outputText value="#{currentOrder.customer.address.zip}, \
                #{currentOrder.customer.address.region}, #{currentOrder.customer.address.area}, #{currentOrder.customer.address.town}" />
                <h:outputText value="#{messages.address}:" />  <h:outputText value="#{currentOrder.customer.address.address}" />
            </h:panelGrid>

            <p></p>

            <s:button view="/order/pay.xhtml" value="← #{messages.back}" />
            <s:button action="#{checkout.confirm()}" value="#{messages.allRight} →" />
        </h:form>


    </ui:define>

</ui:composition>

</html>